from sys import platform
import torch
import whisper
from typing import List, Optional, Union
from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline


class TranscriberWhisper:
    def __init__(self) -> None:
        self.myDevice = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") # 初始化设备
        self.model = whisper.load_model( # 初始化模型
            name = "large",
            # device = Optional[Union[str, torch.device]],
            download_root = ".\whisper_model"
        )

    def transcribe(self,audio_np):
        result = self.model.transcribe(audio_np)
        return result


if __name__ == '__main__':
    transcriber = TranscriberWhisper()
    print('ok')
